var parentVue = new Vue({
	el: "#effectStatistics",
	data: {
		loading: false,
		ctx: ctx,
		ringGit:'3.4',
		categoryTypes:[],// 报装类型数据
		curHeight: (document.documentElement.clientHeight || document.body.clientHeight),//当前屏幕高度
		period: '',
		value1: '',
		hasOutLine:'1', // 市政是否存在外线工程 1 存在  0 不存在
		activeName: 'szbz',
		activeName2:'szbz',
		dateRange: [],
		tableData: [],
		staticData: {
			jointAllCount: 10,
			waterAllCount: 10,
			electricAllCount: 20,
			gasAllCount: 13
		}, // 饼图数据
		approveActive: '1',
		autoXAxis: [], // 主动服务横坐标
		indicator: {}, // 主动服务数据统计
		unitServes:[], // 主动服务下单位服务数据
		totalLoading: false, // 头部模块的加载效果
		eaProjTotalVo: {}, // 头部【项目总数】模块的数据
		eabzTotalVo: {}, // 头部【报装件总数】模块的数据
		eabzbjTotalVo: {}, // 头部【报装办结率】模块的数据
		eawxjbTotalVo: {}, // 头部【外线接驳申报总数】模块的数据
		spanTimes:[], // 头部【水、电、气 、 通信】模块的数据
		summury:{}, // 市政报装概况series数据
		months:[], // 市政报装概况X轴数据
		overRate:{}, // 头部【平均逾期率】模块的数据
		analysisLoading: false,// 各类型申报统计加载效果
		// bzRegionTotalVos: [], // 各类型申报统计-市政服务报装的表格数据
		categoryTypeVos:[],//报装或外线数据统计
		regionList:[],
		lhbzTotalVo: [], // 各类型申报统计-市政服务报装的联合报装统计
		dxbzTotalVo: [], // 各类型申报统计-市政服务报装的单项报装统计
		// szbzTypeVos: [], // 各类型申报统计-市政服务报装的饼图数据
		// szbzTotal: 0, // 各类型申报统计-市政服务报装的饼图总数
		total:0,//市政报装总数或者 外线申报次数
		itemNums:0, // 办件总数
		applyNum:0, // 申报总数
		outlineRate:0,
		unitApplyRate:0,
		// wxgcRegionTotalVos: [], // 各类型申报统计-外线工程的表格数据
		// wxgcTypeVos: [], // 各类型申报统计-外线工程的饼图数据
		// wxgcTotal: 0, // 各类型申报统计-外线工程的饼图总数
		startTime: '', // 开始时间yyyy-MM-dd HH:mm:ss
		endTime: '', // 结束时间
		lineChartData: [], // 主动服务线性图数据
		lineLoading: false, // 底部线性图的加载效果
		dateActive: 'all', // 时间切换类型
		activeCategory: '01', // 各公司平均审批用时当前分类
		activeCategoryIndex:'0',
		approveInfoLoading: false,
		xAxisBar: [],
		dicRegions: [], // 区域下拉框数据
		dicRegionFirst: {}, // 第一个城市
		searchForm: {
			daterange: [],
			itemCategoryTypes: [],
			regions: ['all'],
			keyword: '',
			curRegion: '全部',
			regionNames: [],
			pageNum: 1,
			pageSize: 5
		},
		unitApproveTimes:[],//各公司审批用时
		itemCompleteNum:0,
		overDateNum:0,
		avgApproveTime:'0',
		avgSpanTime:'0',
		overDateRate:'0',
	},
	created: function () {
		// this.getTotal();
		this.getListBscDicRegion();
		this.listCategoryTypes();
	},
	mounted: function () {
		this.changeDate('all')
	},
	methods: {
		getListBscDicRegion: function () {
			var ts = this
			request('', {
				type: 'get',
				url: ctx + 'rest/conditional/query/listBscDicRegion'
			}, function (res) {
				if (res.success) {
					if (res.content && res.content.length) {
						ts.dicRegionFirst = res.content[0]
						ts.dicRegions = res.content[0].children.map(function (item) {
							ts.$set(item, 'isCheck', false)
							return item
						})
						ts.dicRegions.unshift({
							regionId: 'all',
							regionName: '全部',
							isCheck: true
						})
						ts.dicRegions.push({
							regionId:  ts.dicRegionFirst.regionId,
							regionName: '市区',
							isCheck: false
						})
					}
				}
			}, function (err) {

			})
		},

		listCategoryTypes: function () {
			var ts = this
			request('', {
				type: 'get',
				url: ctx + 'civicism/statistics/listCategoryTypes'
			}, function (res) {
				if (res.success) {
					ts.categoryTypes=res.content;
					if(ts.categoryTypes.length>0){
						ts.activeCategory=ts.categoryTypes[0]['value']
					}
				}
			}, function (err) {

			})
		},
		// 自定义表格斑马纹
		tableRowClassName: function (obj) {
			if (obj.rowIndex % 2 === 1) {
				return 'bg-row';
			}
		},
		// 刷新数据
		freshFn: function() {
			this.activeName = 'szbz'
			this.resetLeft();
			this.getEffectivenessAnalysis('szbz');
			this.getActiveServeStatistic();
			this.getListSpanTime();
		},
		categoryTypesChange: function(item,index){
			this.activeCategory = item.value;
			this.activeCategoryIndex = index;
			this.initBar();
		},
		// 切换时间
		changeDate: function (type, key) {
			this.dateActive = type
			if (type === 'dateRange') {
				this.period = '';
				if (this.startTime&&this.endTime) {
					if (this.startTime>this.endTime) {
						this.$message({
							type: 'error',
							message: '开始时间不能大于结束时间！'
						})
						return
					}
					this.freshFn()
				} else {
					// 清除时间时
					if (key ==='endTime'&&!this.endTime) {
						this.dateActive = 'all'
						this.startTime = ''
						this.freshFn()
					}
				}
				return;
			}
			var nowDate = new Date()
			var month = nowDate.getMonth();
			this.endTime = formatDate(nowDate, 'yyyy-MM-dd')
			if (type === 'month') {
				this.period = 'm';
				nowDate.setDate(1)
			} else if (type === 'quarter') {
				this.period = 'q';
				if (month < 3) {
					nowDate.setMonth(0);
				} else if (2 < month && month < 6) {
					nowDate.setMonth(3);
				} else if (5 < month && month < 9) {
					nowDate.setMonth(6);
				} else if (8 < month && month < 11) {
					nowDate.setMonth(9);
				}
				nowDate.setDate(1)
			} else if (type === 'year') {
				this.period = 'y';
				nowDate.setDate(1);
				nowDate.setMonth(0);
			}
			this.startTime = formatDate(nowDate, 'yyyy-MM-dd')
			if (type === 'all') {
				this.period = '';
				this.startTime = ''
				this.endTime = ''
			} else {
				this.startTime = this.startTime;
			}
			this.freshFn()
		},
		// 切换是否有外线工程
		changeHasOutLine:function (val) {
			this.hasOutLine = val;
			this.freshFn();
		},

		// 主动服务统计
		getActiveServeStatistic:function(){
			var ts = this ,params = {};
			if (ts.period){
				params = {
					hasOutLine:ts.hasOutLine,
					period:ts.period
				}
			}else{
				params = {
					hasOutLine:ts.hasOutLine,
					startDate:ts.startTime,
					endDate: ts.endTime,
				}
			}
			if(ts.searchForm.regions && ts.searchForm.regions.length>0 && !(ts.searchForm.regions.indexOf('all') > -1)){
				params.regionIds =  ts.searchForm.regions.join(',');
			}
			request('', {
				type: 'get',
				url: ctx + 'civicism/statistics/activeServe',
				data:params,
			}, function (res) {
				if (res.success&&res.content) {
					ts.autoXAxis = [];
					ts.lineChartData = [];
					var respData = res.content;
					ts.indicator = {
						allCounts:respData.serveNum || 0,
						thisMonthCounts:respData.curMonthAdd || 0,
						growthRate:respData.ringGit,
						growth:respData.growth,
					}
					ts.unitServes = respData.unitServes;
					var months = respData.months;
					var monthData = respData.monthData;
					months.forEach(function (item){
						ts.autoXAxis.push(item)
					})
					monthData.forEach(function(item){
						for (var itemKey in item) {
							ts.lineChartData.push({
								serieName: itemKey||'-',
								data: item[itemKey]
							})
						}
					})
					ts.initLine()
				}
				ts.lineLoading = false
			}, function (err) {
				ts.lineLoading = false
			})
		},

		// 跨度用时及半年数据概览接口
		getListSpanTime:function () {
			var ts = this,params={};
			if (ts.period){
				params = {
					hasOutLine:ts.hasOutLine,
					period:ts.period
				}
			}else{
				params = {
					hasOutLine:ts.hasOutLine,
					startDate:ts.startTime,
					endDate:ts.endTime,
				}
			}
			if(ts.searchForm.regions && ts.searchForm.regions.length>0 && !(ts.searchForm.regions.indexOf('all') > -1)){
				// params.regionIds =  JSON.stringify(ts.searchForm.regions);
				params.regionIds =  ts.searchForm.regions.join(',');
			}
			ts.totalLoading = true;
			request('', {
				type: 'get',
				url: ctx + 'civicism/statistics/listSpanTime',
				data:params,
			}, function (res) {
				ts.totalLoading = false;
				if (res.success&&res.content) {
					var respData = res.content;
					for (var respDataKey in respData) {
						ts[respDataKey] = respData[respDataKey];
					}
					var avgScore = respData.avgScore;
					// 接口返回数据为null处理
					if(ts.overRate == null){
						ts.overRate = {}
					}
					ts.initGeneralSituation();
					ts.initBar()
					ts.initEnterpriseChart(avgScore,avgScore*10*2);
				}
			}, function (err) {
				ts.totalLoading = false;
			})
		},
		/**
		 * 获取各类型申报统计
		 * 根据标签页切换请求不同的接口
		 * szbz: 市政报装
		 * wxgc： 外线工程
		 * **/
		getEffectivenessAnalysis: function (urlName) {
			var ts = this
			ts.analysisLoading = true
			var params = {
				startDate: ts.startTime,
				endDate: ts.endTime
			}
			if(ts.searchForm.regions && ts.searchForm.regions.length>0 && !(ts.searchForm.regions.indexOf('all') > -1)){
				params.regionIds =  ts.searchForm.regions.join(',');
			}

			request('', {
				type: 'get',
				url: ctx + 'civicism/statistics/' + urlName,
				data: params,
			}, function (res) {
				if (res.success) {
					var resData = res.content
					for (var key in resData) {
						if (ts.hasOwnProperty(key)) {
							ts[key] = resData[key]
						}
					}
					if (ts.activeName === 'wxgc') {
						ts.$nextTick(function () {
							ts.initOutPieCahrt()
						})
					} else {
						ts.initPieChart()
					}
				}
				ts.analysisLoading = false
			}, function (err) {
				ts.analysisLoading = false
			})
		},
		// 获取总数rest/effectivenessAnalysis/total
		/*getTotal: function () {
			var ts = this
			ts.totalLoading = true
			request('', {
				type: 'get',
				url: ctx + 'civicism/statistics/total',
			}, function (res) {
				if (res.success) {
					var resData = res.content
					for (var key in resData) {
						if (ts.hasOwnProperty(key)) {
							ts[key] = resData[key]
						}
					}
				}
				ts.totalLoading = false
			}, function (err) {
				ts.totalLoading = false
			})

		},*/
		// 初始化【各类型申报统计-市政服务报装】的饼图
		initPieChart: function () {
			var keys = [
				{
					key: 'total',
					name: '联合报装',
				}, {
					key: 'total',
					name: '用水报装',
				}, {
					key: 'total',
					name: '用电报装',
				}, {
					key: 'total',
					name: '用气报装'
				}]//没用到
			var option = this.initPie('pieChart', 'categoryTypeVos', keys, '市政服务报装', '', 'itemNums')
			// 自适应图表
			window.addEventListener('resize',function(){
				echarts.init(document.getElementById('pieChart')).resize();
			})
			echarts.init(document.getElementById('pieChart')).setOption(option);
		},
		// 初始化【各类型申报统计-外线工程】的饼图
		initOutPieCahrt: function () {
			var keys = [
				{
					key: 'waterAllCount',
					name: '用水外线接驳',
				}, {
					key: 'electricAllCount',
					name: '用电外线接驳',
				}, {
					key: 'gasAllCount',
					name: '用气外线接驳'
				}]
			var option = this.initPie('outPieCahrt', 'categoryTypeVos', keys, '外线工程', '', 'applyNum')
			// 自适应图表
			window.addEventListener('resize',function(){
				echarts.init(document.getElementById('outPieCahrt')).resize();
			})
			echarts.init(document.getElementById('outPieCahrt')).setOption(option);
		},

		tabClick: function () {
			this.getEffectivenessAnalysis(this.activeName)
		},
		tabClick2: function () {

		},
		handleClick: function () {

		},
		// 各公司平均审批用时柱状图
		initBar: function () {
			var ts = this
			var chartDom = document.getElementById('approveTime');
			var barChart = echarts.init(chartDom);
			var colors = ['#179BFF', '#5AD8A6', '#FF7368'],
				units = [' 天',' 工作日','%'], data1 = [], data2 = [], data3 = [];
			var resData=[];
			ts.xAxisBar=[];
			/*if(ts.unitApproveTimes && ts.unitApproveTimes[ts.activeCategory]){
				resData = ts.unitApproveTimes[ts.activeCategory]
				resData.forEach(function(item) {
					ts.xAxisBar.push(item.orgName)
				})
			}
			resData.forEach(function(item) {
				data1.push(item.avgSpanTime)
				data2.push(item.avgApproveTime)
				data3.push(item.overDateRate)
			})*/
			var unitApproveTimes = JSON.parse(JSON.stringify(ts.unitApproveTimes))
			if(unitApproveTimes){
				var activeData =  unitApproveTimes[ts.activeCategory] || [];
				delete unitApproveTimes[ts.activeCategory];
				var noActiveData = unitApproveTimes;
				activeData.forEach(function(v){
					resData.push(v);
				})
				for (var noActiveDataKey in noActiveData) {
					noActiveData[noActiveDataKey].forEach(function(t){
						resData.push(t);
					})
				}
				resData.forEach(function(item) {
					ts.xAxisBar.push(item.orgName)
				})
				resData.forEach(function(item) {
					data1.push(item.avgSpanTime)
					data2.push(item.avgApproveTime)
					data3.push(item.overDateRate)
				})
			}
			var option = {
				title: {
					text: '各公司平均审批用时'
				},
				tooltip: {
					trigger: 'axis',
					axisPointer: { // 坐标轴指示器，坐标轴触发有效
						type: 'shadow', // 默认为直线，可选为：'line' | 'shadow'
						shadowStyle: {
							color: '#f7f7f7',
						},
						z: -1,
					},
					borderWidth: 0,
					formatter: function (params) {
						var str = ''
						params.forEach(function (item, index) {
							str = str + '<p style="font-weight: normal;line-height: 32px;">' + item.seriesName + ':<span style="color: ' + colors[index] + '; padding:0 0 0 10px;">' + item.data +units[index] + '</span></p>'
						})

						return str
					},
					backgroundColor: 'rgba(13,28,40,.9)',
					textStyle: {
						color: '#fff',
						lineHeight: 32,
					},
				},
				/*legend: {
					data: ['平均跨度用时', '平均审批用时','逾期率'],
					left: '40%',
					icon: 'rect',
					itemHeight: 10,
					itemWidth: 10,
					itemGap: 16,
					left: '180px',
					top: '3px'
				},*/
				legend: {
					x:'left',
					padding:[10,0,0,250],
					itemWidth: 10,
					itemHeight: 10,
					selectedMode:false,
					data: [
						{
							name:'平均跨度用时',
							textStyle:{
								fontSize:14,
								fontWeight:'400',
								color:'#575962'
							},
							icon:'circle'
						},
						{
							name:'平均审批用时',
							textStyle:{
								fontSize:14,
								fontWeight:'400',
								color:'#575962'
							},
							icon:'circle'
						},
						{
							name:'逾期率',
							textStyle:{
								fontSize:14,
								fontWeight:'400',
								color:'#575962'
							},
							icon:'line'
						}
					]
				},
				grid: {
					top: '130px',
					left: '45px',
					right: '45px',
					bottom: '32px',
				},
				xAxis: {
					type: 'category',
					axisTick: {
						show: false,
					},
					axisLine: {
						show: false,
					},
					axisPointer: {
						type: 'shadow'
					},
					data: ts.xAxisBar
				},
				yAxis: [{
					type: 'value',
					axisLabel: {
						formatter: '{value} 日'
					},
					axisTick: {
						show: false,
					},
					axisLine: {
						show: false,
					},
					splitLine:{//分割线
						show:true,
						lineStyle: {
							type:'dashed',
							color: "rgba(223,224,226,1)",
						}
					}
				}, {
					type: 'value',
					splitLine: {
						show: false,
					},
					interval: 50,
					min: 0,
					max: 100,
					axisLabel: {
						formatter: '{value} %'
					},
					axisTick: {
						show: false,
					},
					axisLine: {
						show: false,
					}
				}],
				series: [{
					name: '平均跨度用时',
					barMaxWidth: 10,
					data: data1,
					type: 'bar',
					itemStyle: {
						normal: {
							// 统一设置四个角的圆角大小
							barBorderRadius: 7,
							//设置柱状图颜色渐变
							color:"#179BFF"
						}
					},
				}, {
					name: '平均审批用时',
					barMaxWidth: 10,
					data: data2,
					type: 'bar',
					itemStyle: {
						normal: {
							// 统一设置四个角的圆角大小
							barBorderRadius: 7,
							//设置柱状图颜色渐变
							color:"#5AD8A6"
						}
					},
				}, {
					name: '逾期率',
					yAxisIndex:1, // 与第二个y轴数据对着
					barMaxWidth: 10,
					data: data3,
					type: 'line',
					itemStyle: {
						color:"#FF7368"
					},
				},]
			};
			// 自适应图表
			window.addEventListener('resize',function(){
				barChart.resize();
			})
			option && barChart.setOption(option);
		},
		// 市政服务报装饼图
		/**
		 * domId: 节点id名
		 * dataName： 数据名
		 * keys：数据键名
		 * seriesName: 饼图名称
		 * */
		initPie: function (domId, dataName, keys, seriesName, echartName, graphicTxt) {
			var ts = this;
			// 获取数据
			var seriesData = []
			var color = [];
			ts[dataName].forEach(function (item) {
				seriesData.push({
					value: item.total,
					name: item.categoryTypeName
				})
				if(item.categoryType === '01'){
					color.push('#179BFF')
				}else if(item.categoryType === '02'){
					color.push('#FBC953')
				}else if(item.categoryType === '03') {
					color.push('#FF7368')
				}else{
					color.push('#5AD8A6')
				}
			})
			var series = [
				{
					name: seriesName,//代表a的值，系列名称
					type: 'pie',
					center: ['50%', '50%'], //饼图的中心（圆心）坐标，数组的第一项是横坐标，第二项是纵坐标。
					radius: ['50%', '62%'],//饼图的半径，数组的第一项是内半径，第二项是外半径。[ default: [0, '75%'] ]
					/*  animation: false, */  //是否禁用动画效果
					label: {
						normal: {
							labelwidth: 10,
							show: true,//是否显示标签
							//标签的位置。'outside'饼图扇区外侧，通过视觉引导线连到相应的扇区。'inside','inner' 同 'inside',饼图扇区内部。'center'在饼图中心位置。
							position: 'left',//显示的标签的内容
							//a（系列名称），b（数据项名称），c（数值）, d（百分比）
							formatter: [
								'{a|{b}}',
								'{b|{c}}',
								'{b|{d}%}'
							].join('\n'), //  ![在这里插入图片描述](https://img-blog.csdn.net/2018101313580390?watermark/2/text/aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM5MzI3NDE4/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70)
							rich: {
								a: {
									align: 'left',
									color: 'rgba(61,73,83,1)',
								},
								b: {
									align: 'left',
									fontSize: '24',
									color: 'rgba(13,28,40,1)',
									fontWeight: 'bold',
									lineHeight: 32
								}
							},
						},
						emphasis: {
							//鼠标放在圆环上显示的标签样式
							show: true,
							textStyle: {
								fontSize: '12',
								fontWeight: 'bold'
							}
						}
					},
					labelLine: {
						length: 20,
						length2: 50,
						lineStyle: {
							color: '#DFE1E2'
						}
					},
					/*itemStyle: {
						normal: {
							borderColor: "#FFFFFF",
							borderWidth: 1,
							label: {
								show: true,
								formatter: '{d}%'
							},
							lineStyle: {
								width:0.1
							}
						}
					},*/ // 区域间隔
					// 系列中的数据内容数组。
					data: seriesData
				}
			]
			if (ts.activeName === 'szbz') {
				series.unshift({
					name: '报装',//代表a的值，系列名称
					type: 'pie',
					radius: ['37%', '43%'],
					color: ['rgba(63,164,244,1)', 'rgba(246,131,78,1)'],
					label: {
						formatter: "{d}%",
						position: 'inner',
						fontSize: 14,
					},
					labelLine: {
						show: false
					},
					data: [
					]
				})
			} else {
				series[0].radius = ['50%', '62%']
			}
			var option = {
				title: {//标题组件
					textStyle: {
						color: "#333333",
						fontSize: 12,
					}
				},
				tooltip: {
					trigger: 'item',
					backgroundColor: 'rgba(13,28,40,.9)',
					formatter: function (val) {
						if (val.seriesName === '报装') {
							return '<div class="pie-box"><p class="pie-css">' + val.name + '</p>' + '<p class="pie-css"><span>报装总数：</span>' + val.total + '</p>' + '<p class="pie-css"><span>申报次数：</span>' + val.data.value1 + '</p></div>'
						} else {
							return val.name + '：' + val.percent + '%'
						}
					},
				},
				// tooltip: {
				// 	trigger: 'item',
				// 	formatter: "{b}:{d}%",
				// 	textStyle: {    //图例文字的样式
				// 		color: '#fff',  //文字颜色
				// 		fontSize: 10    //文字大小
				// 	}
				// },
				graphic: [
					{
						type: 'text',
						top: '42%',
						left: 'center',
						style: {
							text: ts[graphicTxt],
							fill: '#000000',
							fontSize: 48,
							fontWeight: '700'
						},
						// 事件的监听器，还可以是 onmousemove, ondrag 等。支持的事件参见下。
						onmouseover: function () {
							document.getElementsByClassName('custom-graphic-tooltip')[0].style.display='block';
						},
						onmouseout: function () {
							document.getElementsByClassName('custom-graphic-tooltip')[0].style.display='none';
						}
					}, {
						type: 'text',
						top: '57%',
						left: 'center',
						style: {
							text: ts.activeName === 'szbz'?'报装办件总数':'申报总次数',
							fill: '#000000',
							fontSize: 16,
							fontWeight: 'normal'
						},
					},
				],
				//圆环的颜色
				color: color,
				// 图例
				/*legend: {
					// 图例选择的模式，控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择，可以设成 false 关闭。
					selectedMode: false,
					orient: 'vertical',
					left: 10,
					right: 0,
					top: 20,
					top: '400px',
					itemWidth: 6,  //图例标记的图形宽度
					itemHeight: 6, //图例标记的图形高度
					data: ['联合报装', '用水报装', '用电报装', '用气报装'],
					textStyle: {    //图例文字的样式
						color: 'rgba(13,28,40,1)',  //文字颜色
						fontSize: 16,    //文字大小
						rich: {
							a: {
								align: 'left'
							},
							b: {
								fontSize: 16,
								padding:[0,0,0,407],
							}
						}
					},
					formatter:  function(name){
						var arr = [
							'{a|' + name + '}',
							'{b|'+ obj[name]+'}',
						]
						return arr.join('')
					},
				},*/
				series: series
			};
			return option
		},
		// 主动服务
		initLine: function () {
			var ts = this
			var lineChart = echarts.init(document.getElementById('lineChart'));
			var series = [],legendData = [];
			ts.lineChartData.forEach(function (item) {
				series.push({
					name: item.serieName,
					type: 'line',
					//stack: '总量',
					symbol: 'circle', // 拐角点的图标设置成实心圆点
					showSymbol: false, // 鼠标悬浮再显示拐角点的图标
					data: item.data,
				})
				legendData.push({
					name:item.serieName,
						textStyle:{
							fontSize:12,
							fontWeight:'400',
							color:'#2C3542'
						},
					icon:'circle'
				})
			})

			var option = {
				// title: {
				// 	text: '主动服务'
				// },
				legend: {
					x:'left',
					padding:[2,0,0,45],
					itemWidth: 10,
					itemHeight: 10,
					data:legendData,
				},
				color: ['#179bff', '#FBC953', '#FF7368','#5AD8A6'],
				tooltip: {
					trigger: 'axis',
					backgroundColor: 'rgba(13,28,40,.9)',
					formatter: function (params,ticket,callback) {
						var res = params[0].name;
						//使用for可以将需要的数据全部加到res
						//注意下边的<br/>
						for (var i = 0, l = params.length; i < l; i++) {
							res += '<br/>' + params[i].seriesName + ' : ' + params[i].value;
						}
						return res;
					},
				},
				grid: {
					top: '12%',
					left: '3%',
					right: '4%',
					bottom: '0%',
					containLabel: true
				},
				xAxis: {
					type: 'category',
					data: ts.autoXAxis,
					axisTick: {
						show: false,
					},
					axisPointer: {
						label: {
							// formatter: function (params) {
							// 	var date = new Date()
							// 	var year = date.getFullYear() + "";
							// 	return year + '-' + params.value.split('月')[0];
							// }
						}
					}
				},
				yAxis: {
					type: 'value',
					axisTick: {
						show: false,
					},
					axisLine: {
						show: false,
					},
					splitLine: {
						lineStyle: {
							type: 'dashed',
							color: 'rgba(223,225,226,1)'
						}
					}
				},
				series: series
				/*[
				{
					name: '供电服务',
					type: 'line',
					stack: '总量',
					symbol: 'circle', // 拐角点的图标设置成实心圆点
					showSymbol: false, // 鼠标悬浮再显示拐角点的图标
					data: [12, 13, 10, 13, 9, 23, 21, 33]
				},
				{
					name: '供气服务',
					type: 'line',
					stack: '总量',
					symbol: 'circle',
					showSymbol: false,
					data: [22, 18, 19, 23, 29, 33, 31, 45]
				},
				{
					name: '供水服务',
					type: 'line',
					stack: '总量',
					symbol: 'circle',
					showSymbol: false,
					data: [15, 23, 20, 15, 19, 33, 41, 23]
				},
			]*/
			}
			// 自适应图表
			window.addEventListener('resize',function(){
				lineChart.resize();
			})
			lineChart.setOption(option);
		},

		// 初始化企业满意度图表
		initEnterpriseChart:function (avgScore,avgScore2){
			var chartDom = document.getElementById('enterprise-satisfaction');
			var myChart = echarts.init(chartDom);
			var option;

			var placeHolderStyle = {
				normal: {
					label: {
						show: false
					},
					labelLine: {
						show: false
					},
					color: "rgba(0,0,0,0)",
					borderWidth: 0
				},
				emphasis: {
					color: "rgba(0,0,0,0)",
					borderWidth: 0
				}
			};
			// 仪表盘外层
			var roundList = [
				{
					type: "pie",
					z:2,
					hoverAnimation: false, //鼠标经过的特效
					radius: ["60%", "69%"], // 内半径、外半径
					center: ["40%", "50%"], // 圆心坐标, 距离左侧、顶部
					startAngle: 180, // 0 为圆心左侧开始，起始角度，支持范围[0, 360]。
					labelLine: {
						normal: {
							show: false
						}
					},
					label: {
						normal: {
							position: "center"
						}
					},
					data: [
						{
							value: 33,
							itemStyle: {
								normal: {
									color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
										// 0% 处的颜色
										offset: 0, color: '#7D6CFC'  },
										{
											// 100% 处的颜色
											offset: 1, color: '#FF7368'
										}], false)
								}
							}
						},
						{
							value: 0.7,
							itemStyle: {
								normal: {
									color: "#fff"
								}
							}
						},
						{
							value: 37,
							itemStyle: {
								normal: {
									color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
										// 0% 处的颜色
										offset: 0, color: '#569FE5'  },
										{
											// 100% 处的颜色
											offset: 1, color: '#786DFB'
										}], false)
								}
							}
						},
						{
							value: 0.7,
							itemStyle: {
								normal: {
									color: "#fff"
								}
							}
						},
						{
							value: 18,
							itemStyle: {
								normal: {
									color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
										// 0% 处的颜色
										offset: 0, color: '#53C1BF'  },
										{
											// 100% 处的颜色
											offset: 1, color: '#54E099'
										}], false)
								}
							}
						},
						{
							value: 100,
							itemStyle: placeHolderStyle
						}
					]
				},
			];

			var bg = [
				{
					type: "pie",
					radius: "69%", // 半径
					center: [
						// 圆心
						"40%",
						"50%"
					],
					z: 1,
					itemStyle: {
						normal: {
							color: {
								type: "linear",
								x: 0,
								y: 0,
								x2: 0,
								y2: 1,
								colorStops: [
									{
										offset: 0,
										color: "#ffffff" // 0% 处的颜色
									},
									{
										offset: 1,
										color: "#f6f5fa" // 100% 处的颜色
									}
								],
								global: false // 缺省为 false
							},
							label: {
								show: false
							},
							labelLine: {
								show: false
							}
						}
					},
					hoverAnimation: false,
					label: {
						show: false
					},
					tooltip: {
						show: false
					},
					data: [
						{
							value: 70 // 背景部分
						},
						{
							value: 30, // 空缺部分
							itemStyle: {
								color: "transparent"
							}
						}
					],
					startAngle: 216
				}
			];

			var pointer = [
				{
					name: "指针",
					type: "gauge",
					title: {
						show: false
					},
					detail: {
						show: false
					},
					data: [
						{
							value: avgScore2
						}
					],
					startAngle: 180,
					endAngle: -346,
					radius: "67%", // 内半径、外半径
					center: ["40%", "50%"], // 圆心坐标, 距离左侧、顶部
					itemStyle: {
						color: "#5B595A"
					},
					axisLine: {
						lineStyle: {
							show: false,
							width: 0
						}
					},
					axisLabel: {
						show: false
					},
					axisTick: {
						show: false
					},
					splitLine: {
						show: false
					},
					pointer: {
						show: true,
						length: "73%",
						width: '28%'
					},
					zlevel: 0
				}
			];


			var circles = [
				{
					type: "pie",
					radius: "48", // 半径
					center: [
						// 圆心
						"40%",
						"50%"
					],
					z:98,
					itemStyle: {
						normal: {
							color: "#fff",
							label: {
								show: true
							},
							labelLine: {
								show: false
							},
							shadowColor: "rgba(122, 122, 122, 0.21)",
							shadowBlur: 50
						}
					},
					animation: false,
					tooltip: {
						show: false
					},
					data: [
						{
							value:avgScore, // 背景部分
							label: {
								normal: {
									formatter: "{c}",
									position: "center",
									show: true,
									textStyle: {
										fontSize: "30",
										fontFamily: "Impact",
										fontWeight: "normal",
										color: "#4a4a4a"
									}
								}
							}
						},
						{
							value:"平均分", // 背景部分
							label: {
								normal: {
									formatter: "{c}",
									position: "center",
									show: true,
									textStyle: {
										color: "#78828A",
										fontFamily: "PingFangSC-Semibold",
										fontWeight: "normal",
										fontSize: "12",
										textAlign: "center"
									}
								}
							}
						},
					],
					startAngle: 0,
					text: "36%",
					textStyle: {
						color: "#000"
					}
				},
			];

			var texts = [];


			option = {
				backgroundColor: "#fff",
				title: [
					{
						text: "差",
						left: "13%",
						top: "35%",
						textAlign: "center",
						textStyle: {
							fontWeight: "normal",
							fontFamily: "PingFangSC-Semibold",
							fontSize: "12",
							color: "#78828A",
							textAlign: "center"
						}
					},
					{
						text: "一般",
						left: "38%",
						top: "8%",
						textAlign: "center",
						textStyle: {
							fontWeight: "normal",
							fontFamily: "PingFangSC-Semibold",
							fontSize: "12",
							color: "#78828A",
							textAlign: "center"
						}
					},
					{
						text: "满意",
						left: "65%",
						top: "30%",
						textAlign: "center",
						textStyle: {
							color: "#78828A",
							fontFamily: "PingFangSC-Semibold",
							fontWeight: "normal",
							fontSize: "12",
							textAlign: "center"
						}
					},
				],
				series: [
					...bg, // 背景
					...roundList, // 最外面顶部样式
					...pointer, // 指针
					...circles, // 中间圆圈部分
					...texts // 左右侧文字
				]
			};

			myChart.setOption(option);
			// 自适应图表
			window.addEventListener('resize',function(){
				myChart.resize();
			})

			option && myChart.setOption(option);
		},

		// 初始化市政报装概况图表
		initGeneralSituation:function(){
			var ts = this;
			var chartDom = document.getElementById('general-situation');
			var myChart = echarts.init(chartDom);
			var option;
			var series = [];
			var color = []; // ['#FF925F','#179BFF'],
			for (var summuryKey in ts.summury) {
				var serieName = summuryKey;
				var serieData = ts.summury[summuryKey];
				if(summuryKey === '逾期率'){
					var areaStyle = {// 橙红深
						normal: {
							color: new echarts.graphic.LinearGradient(
								0,
								0,
								0,
								1,
								[{
									offset: 0,
									color: "rgba(255,146,95,0.11)"
								},
									{
										offset: 1,
										color: "rgba(255,243,238,0.11)"
									}
								],
								false
							),
						}
					};
					series.push({
						lineStyle: {
							normal: {
								width:1,
							}
						},
						areaStyle:areaStyle,
						smooth: true,
						symbolSize: 2,
						zlevel: 3,
						name: serieName,
						type: 'line',
						symbol: 'circle', // 拐角点的图标设置成实心圆点
						yAxisIndex:1,
						showSymbol: false, // 鼠标悬浮再显示拐角点的图标
						data: serieData,
					})
					color.push('#FF925F')
				}else{ // 蓝色深
					var areaStyle = {
						normal: {
							color: new echarts.graphic.LinearGradient(
								0,
								0,
								0,
								1,
								[{
									offset: 0,
									color: "rgba(23,155,255,.14)"
								},
									{
										offset: 1,
										color: "rgba(222,241,255,0.14)"
									}
								],
								false
							),
						}
					};
					series.push({
						lineStyle: {
							normal: {
								width:1,
							}
						},
						areaStyle:areaStyle,
						smooth: true,
						symbolSize: 2,
						zlevel: 3,
						name: serieName,
						type: 'line',
						symbol: 'circle', // 拐角点的图标设置成实心圆点
						yAxisIndex:0,
						showSymbol: false, // 鼠标悬浮再显示拐角点的图标
						data: serieData,
					})
					color.push('#179BFF')
				}
			}
			console.log(color)
			option = {
				tooltip: {
					trigger: 'axis'
				},
				color:color,
				legend: {
					x:'left',
					padding:[0,0,0,10],
					itemWidth: 8,
					itemHeight: 8,
					data: [
							{
								name:'逾期率',
								textStyle:{
									fontSize:14,
									fontWeight:'400',
									color:'#333333'
								},
								icon:'circle'
							},
							{
								name:'报装数',
								textStyle:{
									fontSize:14,
									fontWeight:'400',
									color:'#333333'
								},
								icon:'circle'
							}
					]
				},
				grid: {
					top:'20%',
					left: '3%',
					right: '8%',
					bottom: '0%',
					containLabel: true
				},
				toolbox: {
					show: false,
					feature: {
						saveAsImage: {}
					}
				},
				xAxis: {
					type: 'category',
					boundaryGap: false,
					axisTick: {
						show: false,
					},
					axisLine: {
						show: false,
					},
					data: ts.months,
				},
				yAxis:[
					{
						type:'value',
						name:'',
						axisLabel:{
							formatter:'{value}'
						},
						splitLine:{//分割线
							show:true,
							lineStyle: {
								type:'dashed',
								color: "rgba(240,240,240,1)",
							}
						},
						axisTick: {
							show: false,
						},
						axisLine: {//轴线
							show: false,
						},
					},
					{
						type:'value',
						name:'%',
						axisLabel:{
							formatter:'{value}'
						},
						axisLine:{//轴线
							show:false
						},
						splitLine:{//分割线
							show:true,
							lineStyle: {
								color: "rgba(240,240,240,1)",
							}
						}
					}
				],
				series:series
			};
			// 自适应图表
			window.addEventListener('resize',function(){
				myChart.resize();
			})
			option && myChart.setOption(option);
		},
		handleCommand: function (command) {
			console.log(command)
			if (command.regionName !== '全部' && this.dicRegions[0].isCheck) {
				this.$set(this.dicRegions[0], 'isCheck', false)
			}
			command.isCheck = !command.isCheck
			if (this.isMultiple && command.isCheck) {
				this.searchForm.push(command.regionName)
				this.searchForm.regions.push(command.regionId)
				this.searchForm.curRegion = this.searchForm.regionNames.join(',')
			} else {
				this.searchForm.regions = [command.regionId]
				this.searchForm.curRegion = command.regionName
			}
			this.freshFn()
		},
		// 自定义控制条颜色
		customColorMethod:function (item) {
			switch(item.categoryType) {
				case '01':
					return '#179BFF';
					break;
				case '02':
					return '#FBC953';
					break;
				case '03':
					return '#FF7368';
					break;
				default:
					return '#5AD8A6';
			}
		},
		preButtonClick:debounce(function () {
			var vm = this;
			function move(){
				var left  = parseInt($(".picList").css('left'));
				var unitItemWidth = $(".picList .unit-item:nth-child(2)").width()+parseInt($(".picList .unit-item:nth-child(2)").css('margin-left'))
				if(left < -1){
					var leftVal = left + unitItemWidth
					$(".picList").stop().animate({left:leftVal+'px'});
				}else{
					$(".picList").css({left:"0px"});
					vm.$message('已经是第一个')
				}
			}
			move();
		},800),
		nextButtonClick:debounce(function () {
			var left  = parseInt($(".picList").css('left'));
			var ulLength   = this.unitServes.length*308;
			var visibleUlLength = $(".auto-service ").width() - parseInt($(".picScroll-left .bd").css('margin-left'))*2;
			var canMoveLength = ulLength - visibleUlLength;
			var unitItemWidth = $(".picList .unit-item:nth-child(2)").width()+parseInt($(".picList .unit-item:nth-child(2)").css('margin-left'))
			if(Math.abs(left) <= canMoveLength){
				var leftVal = left - unitItemWidth
				$(".picList").stop().animate({left:leftVal+'px'});
			}else {
				this.$message('已经是最后一个')
			}
		},800),
		resetLeft:function () {
			$(".picList").css('left','0px');
		}
	},
})


function debounce(func, wait, immediate) {
	var timeout

	return function () {
		var context = this;
		var args = arguments;

		if (timeout) {
			clearTimeout(timeout);
		}
		if (immediate) {
			// 如果已经执行过，不再执行
			var callNow = !timeout;
			timeout = setTimeout(function(){
				timeout = null;
				func.apply(context, args)
			}, wait)
			if (callNow) func.apply(context, args)
		}
		else {
			timeout = setTimeout(function(){
				func.apply(context, args)
			}, wait);
		}
	}
}